﻿using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace VK.Comm
{
    public class GenericSerializer<T> where T : class
    {
        public GenericSerializer()
        {
        }

        public void Serialize(Stream stream, T obj)
        {
            IFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, obj);
        }

        public T Deserialize(Stream stream)
        {
            IFormatter formatter = new BinaryFormatter();
            return (T)formatter.Deserialize(stream);
        }
    }
}
